﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;

namespace Hedgehog
{
    internal class Bristle : BezierCurve
    {
        private int _x1;
        private int _x2;
        private int _x3;
        private int _y1;
        private int _y2;
        private int _y3;

        public Bristle(int X1, int Y1, int X2, int Y2, int X3, int Y3)
        {
            _x1 = X1;
            _x2 = X2;
            _x3 = X3;
            _y1 = Y1;
            _y2 = Y2;
            _y3 = Y3;

        }

                override public void Draw(Graphics g)
                {
                    bool firstIteration = true;
                    float lastX = 0;
                    float lastY = 0;
                    Random random = new Random();
                    int count = 0;
                    {
                        for (float t = 0; t <= 1; t += (float)0.01)
                        {
                            float newX;
                            float newY;
                            newX = F(t, _x1 + offsetX, _x2 + offsetX, _x3 + offsetX);
                            newY = F(t, _y1 + offsetY, _y2 + offsetY, _y3 + offsetY);

                            if (firstIteration)
                            {
                                lastX = newX;
                                lastY = newY;
                                firstIteration = false;
                                continue;
                            }

                            g.DrawLine(Pens.Black, newX, newY + random.Next(0, 20), newX + random.Next(0, 10), newY - 20 - random.Next(0, 30));
                            count++;
                            
                            lastX = newX;
                            lastY = newY;
                        }



                    }
                  
                }


               override public bool ChekIfPointInside(int x, int y)
                {
                   bool pointInside = x > _x1+offsetX && x < _x3+offsetX && y > _y2 - 40+offsetY && y < _y1+offsetY;


                   return pointInside;
                    
                }
            override   public object Clone()
               {
                   return new Bristle(_x1 , _y1, _x2 , _y2, _x3 , _y3);
               }
            
        
    }
}
